package com.sport.entity.enums;

import com.sport.model.Result;
import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum ErrorMsg {
    SYSTEM_ERROR(-1,"系统繁忙,请开稍候再试"),
    ACCESS_TOKEN_ERROR ( 40001,"AppSecret错误"),
    INVALID_APPID(40013,"不合法的AppID"),
    NVALID_GRANT__TYPE (40002,"不合法的凭证类型"),
    INVALID_SECRET(40125,"不合法的secret"),
    IP_ERROR(40164,"调用接口的IP地址不在白名单中"),
    SECRET_MISS(41004,"缺少secret参数"),
    DISABLED_TOKEN( 50004,"禁止使用token接口"),
    AcCOUNT_DISABLED(50007,"账号已冻结"),
    THIRD_ERROR(61024,"第三方平台API需要使用第三方平台专用token" ),
    Js_CODE_ERROR(40029,"js_code无效"),
    Js_CODE_BEN_USE(40163,"js_code不能使用"),
    API_MORE_ERROR(45011,"API调用太频繁,请稍候再试"),
    USER_WARNING(40226,"高风险软级用户,小程序登录拦截"),
    MEDIA_ERROR(40004,"媒体类型错误（目前支持多媒体类型1音频;2图片）"),
    MS6_ERROR(40129,"场景值错误（目前支持场景1资料﹔2评论﹔3论坛﹔4社交日志)"),
    POST_REQUEST(43302,"方法调用错误,请用post方法调用"),
    PARAIMS_ENPTY(44002,"传递的参数为空"),
    APPID_NO_MATCH_SECRET(43104," appid与 openid不匹配"),
    API_MINUTE_ERROR(44991,"超出接口每分钟调用限制"),
    API_DAY_ERROR(45009,"超出接口每日调用限制"),
    RESULT_MARNING(87014,"内容可能潜在风险"),
    POST_BODY_ERROR(47081,"传递的参数格式不对"),
    TOKEN_ERROR(61010,"会话超时");

    private Integer code;
    private String message;

    public static <T> Result<T> getResult(int code){
        for (ErrorMsg value : ErrorMsg.values()) {
            if(value.code == code){
                return Result.error(value.code,value.message);
            }
        }
        return Result.error(code,"未知错误");
    }

}
